home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr42 / vocshow2.zip / VOC_PC.PKG < prev    next >
Text File  |  1993-06-08  |  2KB  |  65 lines

  1. -- Copyright 1992 by Tom Moran.  May be used by anyone for any purpose.
  2.  
  3. with Calendar,
  4.      Compress,
  5.      PC_Sound,
  6.      Rtext_Io,
  7.      SB_Samples;
  8.  
  9. package body Voc_PC is
  10.  
  11.   function "=" (Left,Right : in Voc_Data.Block_Types) return Boolean
  12.     renames Voc_Data."=";
  13.  
  14.   function "=" (Left,Right : in Voc_Data.Pack_Types) return Boolean
  15.     renames Voc_Data."=";
  16.  
  17.   procedure Play(Voc_Block: in out Voc_Data.Blocks) is
  18.   begin
  19.     if Voc_Block.Block_Type = Voc_Data.Silence then
  20.       declare
  21.         -- poll for key press for appropriate duration
  22.         use Calendar;
  23.         Time_To_Stop: constant Calendar.Time
  24.           := Calendar.Clock + Voc_Block.Silence_Interval;
  25.       begin
  26.         while Calendar.Clock < Time_To_Stop loop
  27.           exit when Rtext_Io.Keypress;
  28.         end loop;
  29.       end;
  30.       return;
  31.     end if;
  32.     if Voc_Block.Block_Type /= Voc_Data.Voice_Data then
  33.       return;
  34.     end if;
  35.     PC_Sound.Set_Sample_Rate(Voc_Block.Sample_Rate);
  36.     case Voc_Block.Packing is
  37.       when Voc_Data.Unpacked =>
  38.         declare
  39.           Packed_Sound:SB_Samples.Packed_Sounds(1 .. Voc_Block.Block_Length/2);
  40.         begin
  41.           Compress.Pack(Voc_Block.Unpacked_Sound
  42.                           (Voc_Block.Unpacked_Sound'First)'Address,
  43.                         Voc_Block.Block_Length,
  44.                         Packed_Sound);
  45.           PC_Sound.Playback(Packed_Sound(1)'Address,Voc_Block.Block_Length/2);
  46.         end;
  47.       when Voc_Data.Halved =>
  48.         PC_Sound.Playback(Voc_Block.Packed_Sound
  49.                             (Voc_Block.Packed_Sound'First)'Address,
  50.                           Voc_Block.Block_Length);
  51.       when Voc_Data.Thirds =>
  52.         -- this will sound like noise since we don't know how to unpack it
  53.         PC_Sound.Playback(Voc_Block.Packed3_Sound
  54.                             (Voc_Block.Packed3_Sound'First)'Address,
  55.                           (Voc_Block.Block_Length/2)*3);
  56.       when Voc_Data.Quartered =>
  57.         -- this will sound like noise since we don't know how to unpack it
  58.         PC_Sound.Playback(Voc_Block.Packed4_Sound
  59.                             (Voc_Block.Packed4_Sound'First)'Address,
  60.                           (Voc_Block.Block_Length/2)*4);
  61.     end case;
  62.   end Play;
  63.  
  64. end Voc_PC;
  65.